/*
 * main.cpp
 *
 *  Created on: Aug 3, 2013
 *      Author: killerg
 */

#include "robot_deps.h"
#include "bots.h"
#include <google/protobuf/stubs/common.h>
#include "bot.h"
#include <unistd.h>

int main(int argc, char** argv) {
    int botnum = 1;
    int startid = 0;
    int totalnum = -1;
    char* prefix = NULL;
    if (argc == 1) {

    } else if (argc == 2) {
        botnum = atoi(argv[1]);
    } else if (argc == 3) {
        botnum = atoi(argv[1]);
        startid = atoi(argv[2]);
    } else if (argc == 4) {
        botnum = atoi(argv[1]);
        startid = atoi(argv[2]);
        prefix = argv[3];
    } else if (argc == 5) {
        botnum = atoi(argv[1]);
        startid = atoi(argv[2]);
        prefix = argv[3];
        totalnum = atoi(argv[4]);
    } else {
        printf("cmd [botnum] [startid] [prefix] [totalnum]\n");
        return -1;
    }

    srand(time(NULL));
    if (g_bots.init(botnum, startid, prefix, totalnum))
        g_bots.loop();
    g_bots.destroy();

    google::protobuf::ShutdownProtobufLibrary();

}
